package com.xdf.ecommerce.service.communication.hystrix;

import com.xdf.ecommerce.service.communication.AuthorityFeignClient;
import com.xdf.ecommerce.vo.JwtToken;
import com.xdf.ecommerce.vo.UsernameAndPassword;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author chanchaw
 * @create 2025-10-31 8:56
 */
@Service
@Slf4j
public class AuthorityFeignClientFallbackFactory implements FallbackFactory<AuthorityFeignClient> {
    @Override
    public AuthorityFeignClient create(Throwable throwable) {
        log.info("微服务通信 AuthorityFeignClient 出现异常：[{}]", throwable.getMessage(),throwable);
        return new AuthorityFeignClient() {
            @Override
            public JwtToken getToken(UsernameAndPassword usernameAndPassword) {
                return new JwtToken("chanchaw");
            }
        };
    }
}
